package com.cby.leetcode.二分查找.LC2300;


import java.util.Arrays;

/**
 * 二分查找：lowBound
 *
 * 对于查 >= 值的位置，可以用 >>>1 无符号右移1位代替 /2 操作
 *
 */


//这个类只负责启动程序
public class LC2300 {

    public static void main(String[] args){

    }


}

class Solution{

    public int[] successfulPairs(int[] spells, int[] potions, long success) {

        Arrays.sort(potions);

        for (int i = 0; i < spells.length; i++) {
            spells[i] = potions.length - lowBound(potions,(double) success / spells[i]);
        }

        return spells;

    }

    public int lowBound(int[] nums,double target){
        int left = 0;
        int right = nums.length - 1;

        while (left <= right){
            int mid = (left + right) >>> 1;
            if(nums[mid] >= target)
                right = mid - 1;
            else
                left = mid + 1;
        }

        return left;

    }


}

